<template>
  <div class="app-container">
    <div class="filter-container">
      <statisSearchBar :start-date="searchForm.startDate" :end-date="searchForm.endDate" :showp-pf-channel="true" @transferFilter="handleFilter" />
    </div>
    <el-table v-loading="listLoading" :data="list" class="mt-10" stripe border>
      <el-table-column label="日期" prop="date" width="130px" align="center"></el-table-column>
      <el-table-column label="注册" prop="register" width="70px" align="center"></el-table-column>
      <el-table-column label="活跃" prop="dau" width="70px" align="center"></el-table-column>
      <el-table-column label="创角数" prop="actor" width="70px" align="center"></el-table-column>
      <el-table-column label="充值人数" prop="recharge_num" width="70px" align="center"></el-table-column>
      <el-table-column label="充值金额" prop="recharge_amount" width="80px" align="center"></el-table-column>
      <el-table-column label="活跃付费率" prop="dau_pay" width="80px" align="center"></el-table-column>
      <el-table-column label="ARPU" prop="arpu" width="60px" align="center"></el-table-column>
      <el-table-column label="ARPPU" prop="arppu" width="80px" align="center"></el-table-column>
      <el-table-column label="滚服人数" prop="old_actor" width="60px" align="center"></el-table-column>
      <el-table-column label="新增充值人数" prop="recharge_num_new" width="80px" align="center"></el-table-column>
      <el-table-column label="注册充值人数" prop="register_recharge_num_new" width="80px" align="center"></el-table-column>
      <el-table-column label="注册充值金额" prop="register_recharge_amount_new" width="80px" align="center"></el-table-column>
      <el-table-column label="注册付费率" prop="register_pay" width="80px" align="center"></el-table-column>
      <el-table-column label="注册ARPU" prop="register_arpu" width="80px" align="center"></el-table-column>
      <el-table-column label="注册ARPPU" prop="register_arppu" width="80px" align="center"></el-table-column>
      <el-table-column label="次日留存" prop="keep2" width="70px" align="center"></el-table-column>
      <el-table-column label="三日留存" prop="keep3" width="70px" align="center"></el-table-column>
      <el-table-column label="七日留存" prop="keep7" width="70px" align="center"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import StatisSearchBar from '@/components/StatisSearchBar'
import { getPublisherReport } from '@/api/statis'

export default {
  name: 'ReportPublisher',
  components: { StatisSearchBar },
  data() {
    return {
      list: [],
      listLoading: false,
      searchForm: {
        startDate: new Date(Date.now() - 86400000 * 10),
        endDate: new Date()
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleFilter(query) {
      this.searchForm = query
      this.getList()
    },
    async getList() {
      this.listLoading = true
      const res = await getPublisherReport(this.searchForm)
      this.listLoading = false
      this.list = res.data
    }
  }
}
</script>
